begintownscript;
variables;
short choice,i,j,m,n;
body;

beginstate init_state;
	if(get_flag(7,4) == 0) {
		message_dialog("The city of Smolt has been completely demolished, presumably by the golems. The residents of the city didn't even have time to close the city gates before they were upon them. Every building has been razed, save one stone building in the center of town.","");
		set_flag(7,4,1);
}
	if(get_flag(7,1) == 1) {
		set_terrain(25,35,443);
		set_terrain(25,33,137); }
	put_object_on_space(22,26,5);
	put_object_on_space(27,26,6);
	put_object_on_space(24,26,5);
break;

beginstate exit_state;
break;

beginstate start_state;
	m = 24;
	while (m <=  26) {
		n = 25;
			if((is_object_on_space(m,n,5) == 1) || (is_object_on_space(m,n,6) == 1)) {
				message_dialog("The mirror disappears, how odd.","");
				put_object_on_space(m,n,-1); }
				m = m + 1; }
	if(get_terrain(25,35) == 443) {
		if(get_flag(7,1) == 0) {
			message_dialog("You redirect the beam right into the heart of the machinery, and are satisfied when it blows into a million pieces. The beam continues on to blast open the gate to the South.","");
		set_flag(7,1,1); }
				if(get_flag(5,4) == 0) {
					set_flag(250,2,1);
					set_flag(0,8,0); }
}		
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"This control panel has several clearly labeled buttons. You could try your hand at working these beams, but it might not be conductive to a long life.",0);
	add_dialog_str(1,"So what do you do?",0);
	add_dialog_choice(0,"Reset machinery.");
	add_dialog_choice(1,"Leave it alone.");
	choice = run_dialog(1);
	if(choice == 1) {
		j = 26;
		while (j <= 34)
			{i = 21;
			while (i <= 29)
				{put_object_on_space(i,j,-1);
				i = i + 1;
				}
			j = j + 1;
			}
		put_object_on_space(22,26,5);
		put_object_on_space(27,26,6);
		put_object_on_space(24,26,5);
		set_terrain(22,34,384);
		set_terrain(21,34,380);
		set_terrain(21,27,382);
		set_terrain(21,26,388);
		set_terrain(23,27,388);
		set_terrain(23,26,381);
		set_terrain(29,26,382);
		set_terrain(28,26,388);
		set_terrain(29,29,381);
		set_terrain(29,30,388);
		set_terrain(29,31,381);
		set_terrain(27,31,380);
		set_terrain(25,30,382);
		set_terrain(25,29,388);

		 }
		
	if(choice == 2)
		end();
break;

beginstate 11;
	if(get_flag(7,10) == 0)
	{	message_dialog("Whoever controls these golems brought a library of books to this laboratory as well. This is your best chance to gather information, so you should search them thoroughly.","");
		set_flag(7,10,1); }
break;

beginstate 12;
	message_dialog("The logs on this shelf detail the experiments that were performed here, and also in the owner's previous lab. The purpose of this station seems to be controlling the golems from long distances, you take one of the logs with you.","Evidently the golems are difficult to control from long distances, so one of these relay stations is needed to control them if their creator isn't close by. That you destroyed it must be some kind of accomplishment.");
	set_flag(7,8,1);
break;

beginstate 13;
	message_dialog("The books on these shelves range from early accounts of trying to create golems to experiments with long range magical frequencies. You even see some novels mixed in.","Whoever brought these books was in a hurry and didn't bother to sort them, or even see if they were relevant to the studies being conducted here. You gather a few of the more promising books.");
	set_flag(7,8,1);
break;

beginstate 15;
	print_str_color("You search the bookshelf, but find nothing of interest.",2);
break;

beginstate 16;
	if(get_flag(7,3) == 0) {
		message_dialog("Amongst all the ruin of the city of Smolt there is one building standing. It is surrounded by rubble, and the building itself looks like it is newly and hastily, constructed. You might find some clues about the golems in there.","As you approach, some of the piles of rubble shift and stand up, it looks like the building's guards have noticed you.");
		activate_hidden_group(1);
		set_flag(7,3,1); }
break;

beginstate 17;
	if(get_flag(7,5) == 0) {
		message_dialog("You step into the lone structure left in town, and are confronted with an array of machinery beyond anything you've ever seen. Beams are projected across the room, then focused and redirected by several wall sized mirrors.","All of this seems designed to power a large machine in the center of the room. You move closer to see that a large crystal is placed here, and is sending pulses of energy throughout the room.");
		message_dialog("You have no idea what all of this is for, but it can't be a good thing. It couldn't hurt to destroy it.","");
		set_flag(7,5,1);
}
break;

beginstate 18;
	if(get_flag(7,1) == 0)
		if(get_flag(7,6) == 0) {
			message_dialog("The bars of this gate crackle with a strange energy. You strike it with your weapons and receive a strong shock for your efforts. You have nothing that can open this.","");
			set_flag(7,6,1); }
break;

beginstate 19;
	if(get_flag(7,7) == 0) {
		message_dialog("A pass through the Jszoula Mountains once began here, the golems have caved it in using magic. Huge boulders block the path, it will take a crew of workers and months of labor to clear it.","");
		set_flag(7,7,1); }
break;

beginstate 20;
	if(get_flag(250,10) == 0)
	{	reset_dialog();
		add_dialog_str(0,"You look through the bookshelf, scanning over paper after paper without revealing anything of use. You begin to despair of finding any link to the golems' creator when you find a small parcel bound up with string. You rip it open to reveal a journal.",0);
		add_dialog_str(1,"The inside cover has one word written on it, Janok. It is dated 30 years ago. You eagerly flip through it, quickly scanning each page looking for any clues to who this Janok might be.",0);
		add_dialog_str(2,"You intended to merely glance over it, you don't have time to read the whole thing, but the words draw you in like one enchanted. You find yourself pouring over each page.",0);
		add_dialog_choice(0,"OK.");
		choice = run_dialog(1);
		if(choice == 1)
			move_to_new_town(11,38,8);
}
break;

